<% vote = nil %>
<% value = nil %>
<% if @user and @votes.include? @story.id%>
  <% value = @votes[@story.id]%>
<% end %>
<div class="story">
<table>
<tr>
	<% if value == 1 %>
	<td class="voted-up"><%=link_to "yea", :controller => "story", :action => "remove_vote", :id => @story.id, :go_back => request.request_uri%></td>
	<% else %>
	<td class="vote-up"><%=link_to "yea", :controller => "story",:action => "yea", :id => @story.id, :go_back => request.request_uri%></td>
	<% end %>
	<td class="headline"><a href="<%=@story.url%>"><%=@story.title%></a> <%=if @story.url =~ /(:\/\/)([^\/]*)/ then "["+$2+"]" end%></td>
</tr>
<tr>
	<% if value == -1 %>
  <td class="voted-down"><%=link_to "nay", :controller => "story",:action => "remove_vote", :id => @story.id, :go_back => request.request_uri%></td>
  <% else %>
  <td class="vote-down"><%=link_to "nay", :controller => "story",:action => "nay", :id => @story.id, :go_back => request.request_uri%></td>
  <% end %>
  <td class="meta"><%=pluralize @story.points, "point"%>. Posted <%=time_ago_in_words @story.created_on %> ago by <%=@story.user.name%>.</td>	
</tr>
</div>
</table>

<h3>Add Your Two Cents</h3>
<%= render :partial => "form"%>

<h3>Comments</h3>
<%@story.comments.each do |comment|%>
<table>
  <tr>
    <td><em><%=comment.user.name%> posted this <%=time_ago_in_words comment.created_on%> ago:</em></td>
  </tr>	
  <tr>
    <td><%=comment.body%></td> 	
  </tr>
</table>	
<%end%>
